import { MiddlewareConsumer, Module, NestModule } from '@nestjs/common'
import { TypeOrmModule } from '@nestjs/typeorm'
import { Menu } from '@/entities/menu.entity'
import { Permission } from '@/entities/permission.entity'
import { ParentIdMiddleware } from './middleware/parentId.middleware'
import { MenuController } from './menu.controller'
import { MenuService } from './menu.service'

@Module({
  imports: [TypeOrmModule.forFeature([Menu, Permission])],
  controllers: [MenuController],
  providers: [MenuService],
  exports: [MenuService, TypeOrmModule],
})
export class MenuModule implements NestModule {
  configure(consumer: MiddlewareConsumer) {
    consumer.apply(ParentIdMiddleware).forRoutes('systemManage/getMenuList/v2')
  }
}
